package puffer.starter.db.mapper;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.apache.ibatis.annotations.Param;
import puffer.starter.db.entity.Dnt;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author 王永吉
 */
public interface DMapper {
    String TABLE_NAME = "tableName";
    String SQL_SET = "sqlSet";
    String ENTITY = "entity";
    String COLUMNS = "columns";
    String EW = "ew";
    String ENTITY_LIST = "entityList";
    String ID_COLUMN = "idColumn";
    String ID = "id";
    String IDS = "ids";
    String SQL_STRING = "sqlString";

    long _insertOrigin_(@Param(SQL_STRING) String sqlString);

    long _insert_(@Param(TABLE_NAME) String tableName, @Param(ENTITY) Map entity);

    long _updateOrigin_(@Param(SQL_STRING) String sqlString);

    long _countOrigin_(@Param(SQL_STRING) String sqlString);

    Dnt _selectOneOrigin_(@Param(SQL_STRING) String sqlString);

    Object _selectObjOrigin_(@Param(SQL_STRING) String sqlString);

    List<Dnt> _listOrigin_(@Param(SQL_STRING) String sqlString);

    List<Object> _listObjOrigin_(@Param(SQL_STRING) String sqlString);

//   <T> List<T> _listAnyOrigin_(@Param(SQL_STRING) String sqlString, Class<T> t);

    List<Dnt> _pageOrigin_(
            @Param(SQL_STRING) String sqlString,
            @Param("limit") long limit,
            @Param("offset") long offset);

    long _insertBatch_(
            @Param(TABLE_NAME) String tableName,
            @Param(COLUMNS) Collection columns,
            @Param(ENTITY_LIST) List<Dnt> entityList
    );

    long _deleteOrigin_(@Param(SQL_STRING) String sqlString);

    long _deleteById_(@Param(TABLE_NAME) String tableName, @Param(ID) Serializable id, @Param(ID_COLUMN) Object idColumn);

    long _deleteByIds_(@Param(TABLE_NAME) String tableName, @Param(IDS) Collection<?> ids, @Param(ID_COLUMN) Object idColumn);

    long _delete_(@Param(TABLE_NAME) String tableName, @Param(EW) Wrapper<?> wrapper);

    long _updateById_(
            @Param(TABLE_NAME) String tableName,
            @Param(ENTITY) Object entity,
            @Param(ID_COLUMN) Object idColumn,
            @Param(ID) Object id
    );

    long _update_(
            @Param(TABLE_NAME) String tableName,
            @Param(ENTITY) Object entity,
            @Param(SQL_SET) String sqlSet,
            @Param(EW) Wrapper<?> wrapper
    );

    long _updateBatchById_(
            @Param(TABLE_NAME) String tableName,
            @Param(COLUMNS) Collection columns,
            @Param(ENTITY_LIST) List<Dnt> entityList,
            @Param(ID_COLUMN) String idColumn
    );

    long _count_(@Param(TABLE_NAME) String tableName);

    long _count_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<Object> wrapper
    );

    List<Dnt> _list_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<Object> wrapper
    );

    List<Object> _listObj_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<Object> wrapper
    );

//  <T>  List<T> _listAny_(
//            @Param(TABLE_NAME) String tableName,
//            @Param(EW) Wrapper<Object> wrapper
//            , Class<T> t
//    );

    Dnt _selectOne_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<Object> wrapper
    );

    Object _selectObj_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<Object> wrapper
    );

    List<Dnt> _pageWrapper_(
            @Param(TABLE_NAME) String tableName,
            @Param(EW) Wrapper<?> ew,
            @Param("limit") long limit,
            @Param("offset") long offset
    );

}
